package dongshi.daddy.main;

import dongshi.daddy.service.CallbackListener;
import dongshi.daddy.service.MyCallbackService;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class ConsumerWithCallbackMain {
    public static void main(String[] args) throws Exception {
        ClassPathXmlApplicationContext context
                = new ClassPathXmlApplicationContext("consumer-with-callback.xml");
        context.start();
        MyCallbackService callbackService = (MyCallbackService) context.getBean("callbackService");

        callbackService.addListener("foo.bar", new CallbackListener(){
            public void changed(String msg) {
                System.out.println("callback1:" + msg);
            }
        }, new CallbackListener(){
            public void changed(String msg) {
                System.out.println("callback2:" + msg);
            }
        });

        System.in.read();
    }
}
